import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

import com.aliasi.chunk.Chunk;
import com.aliasi.chunk.Chunking;
import com.aliasi.chunk.RegExChunker;


public class SolutionLingpipeRegex {
	
	private static String readFileAsString(String filePath)
    throws java.io.IOException{
        StringBuffer fileData = new StringBuffer(1000);
        BufferedReader reader = new BufferedReader(
                new FileReader(filePath));
        char[] buf = new char[1024];
        int numRead=0;
        while((numRead=reader.read(buf)) != -1){
            String readData = String.valueOf(buf, 0, numRead);
            fileData.append(readData);
            buf = new char[1024];
        }
        reader.close();
        return fileData.toString();
    }
	
	public static void main(String[] args) throws IOException{
		RegExChunker chunker = new RegExChunker("[A-Z][a-z]+","Nome",1);
		String testingFile = readFileAsString("C:\\Users\\Goncalo\\Desktop\\Teste.txt");
		
		Chunking chunking = chunker.chunk(testingFile);
		for (Chunk chunk : chunking.chunkSet()) {
			System.out.println(testingFile.substring(chunk.start(),chunk.end()));
        }
	}
}
